<?php

// Include
include_once('include/header.php');
include_once('plugin/PlanesDBPlugin.php');

// Breadcrumb
$breadcrumb = AppConfigPlugin::getBreadcrumb(basename($_SERVER['PHP_SELF']));
$smarty->assign('breadcrumb', $breadcrumb);


// Ejecucion
if (isset($_POST[sendform])) {
	if (isset($_POST[action]) && ($_POST[action] == "save")) {
		PlanesDBPlugin::update($_POST[id], $_POST[nombre], $_POST[caracgral], $_POST[caracunidad], $_POST[proyinversion]);
		CommonPlugin::setMessage("Se han guardado los cambios en el plan ".$_POST[nombre]);
	}
	header( 'Location: planes.php' );
	exit;	
} else {
	$plan = PlanesDBPlugin::getById($_GET[id]);
}


// Smarty call
$smarty->assign('plan', $plan);

$smarty->display('editplan.tpl');

?>